<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="<%=request.getContextPath()%>/css/pc/login.css"
	type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
</head>
<body onload="setType()">
      <input type="hidden" id="markerType"  value="${type}"/>
      <input type="hidden" id="beforePath" value="${beforePath}" />
	 	<!--
        	作者：offline
        	时间：2016-12-28
        	描述：登录
        -->
        <div class="login">
        	<div class="login_div1">
        		<img class="login_div1_img1" src="<%=request.getContextPath()%>/images/pc/login_01.jpg" />
        		<div class="login_div1_div1">欢迎登录</div>
        		<input class="login_div1_in1" type="text" placeholder="请输入您的邮箱" id="username_login"   value="${pc_user.email}"/>
        		<input class="login_div1_in2" type="password" placeholder="请输入您的密码" id="password_login"  value=""/>
        		<div class="login_div1_div2">
        			<div class="login_div1_div2_div1" id="reminder"></div>
        			<a href="<%=request.getContextPath()%>/login/tobackpwd.htm">忘记密码？</a>
        		</div>
        		<input class="login_div1_in3" type="button" value="登 录" onclick="submitViewBylogin()"/>
        		<div class="login_div1_div3">
        			<input type="checkbox" id="remember_pwd" name="remember_pwd" value=""/>
        			<div>下次自动登录</div>
        			<a href="javascript:register()">立即注册</a>
        		</div>
        	</div>
        </div>
      
</body>
<script type="text/javascript">
	//登录提交验证
	function submitViewBylogin(){
		  var username=$("#username_login").val();
		  var password=$("#password_login").val();
		  var index1=/^([a-zA-Z0-9_\.\-]+)@([a-zA-Z0-9_\.\-]+)\.[c]{1}[o]{1}[m]{1}$/;
		  if(username==""){
			  $("#reminder").html("请输入登录邮箱");
			  $("#username_login").focus();
			  return false;
		  }else if(!index1.test(username)){
			  $("#reminder").html("邮箱格式不正确");
			  $("#username_login").focus();
			  return false;
		  }else if(password==""){
			  $("#reminder").html("请输入登录密码");
			  $("#password_login").focus();
			  return false;
		  }else if(password.length>20){
			  $("#reminder").html("密码长度太长（20字符内）");
			  $("#password_login").focus();
			  return false;
		  }
		  var remember=0;
		  if(document.getElementById("remember_pwd").checked){
			  remember=1;
		  }
		  $.ajax({
          type: "POST",
	          url: "<%=request.getContextPath()%>/login/registerpc.htm",
				data : {
					email : username,
					pwd : password,
					markerType : 1,
					rememberPwd : remember
					
				},
				dataType : "json",
				success : function(data) {
					if(data.state==0){
						$("#reminder").text(data.value);
					}else{
						//登录成功
						var beforePath=$("#beforePath").val();
						if(beforePath==null || beforePath==""){
							beforePath="/newsctr/forum.htm";
						}
						window.location.href="<%=request.getContextPath()%>" + beforePath;
					}
				},
				error : function(error) {
					alert("error");
				}
		});

	}
	 
</script>
</html>